<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>发布微博页面</h1>
<form action="" enctype="multipart/form-data">
    <input type="text" name="content" placeholder="微博正文">
    <input type="file" name="picFile">
    <input type="button" value="发布" @click="insert()">
</form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{},
        methods:{
            insert:function () {
                let data = new FormData(document.querySelector("form"));
                //发出请求
                axios.post("/weibo/insert",data).then(function (res) {
                    if(res.data==1){
                        //发布成功，回到首页
                        location.href="/";
                    }else{//发布失败，未登录
                        alert("请先登录")
                        location.href="/login.html";
                    }
                })
            }
        }
    })
</script>


</body>
</html>